﻿namespace Proto
{
    using System.Collections.Generic;

    public class RunnerRegistry
    {
        public static readonly RunnerRegistry INSTANCE;

        public static readonly Runner APP;
        public static readonly Runner INTEGRATION;
        public static readonly Runner GUI;

        static RunnerRegistry()
        {
            INSTANCE = new RunnerRegistry();
            APP = Get("Application Service");
            INTEGRATION = Get("Integration Service");
            GUI = Get("GUI Serivce");
        }

        public static Runner Get( string name )
        {
            return INSTANCE.GetContext(name);
        }

        private Dictionary<string, Runner> m_ContextLookup = new Dictionary<string, Runner>();
        public Runner GetContext(string name)
        {
            Runner context;
            if( m_ContextLookup.TryGetValue( name, out context ) == false )
            {
                context = new Runner( name );
                m_ContextLookup.Add( name, context );
            }
            return context;
        }
    }
}